<%@ Control Language="C#" ClassName="StateFlow_ActionsByPath" Inherits="Dimok.Web.UI.TableControl" %>
<%@ Register Namespace="Dimok.Web.UI"  Assembly="Dimok.Web.UI" TagPrefix="OR"  %>
<%@ Register Namespace="Data.DataSources" Assembly="App_Code" TagPrefix="DS"  %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="Dimok.Web.UI" %>
<script runat="server">
	public int StateID {
		set {
			ds.SetStateIDParameter(value);
			dsStates.TableName = ds.TableName;
		} 
	}
	public string TableName {	set { ds.TableName = value;	}	}
	protected override void OnPreRender(EventArgs e) {
		//SelectFilter = ds.Filter;
		base.OnPreRender(e);
	}
</script>

<asp:UpdatePanel ID="pnlRebateOffers" UpdateMode="Always" runat="server">
	<ContentTemplate>
		<OR:GridViewEx ID="grv" runat="server" AutoGenerateColumns="False" DataSourceID="ds"
			ShowFooter="True" AllowSorting="True" BackColor="Window" CellPadding="0" EnableTheming="True"
			Font-Names="verdana" EnableViewState="false" DataKeyNames="ID"
			>
			<Columns>

				<asp:TemplateField HeaderText="From" SortExpression="StateFrom">
					<ItemTemplate><asp:Label Text='<%#Eval("StateFrom") %>' runat="server" /></ItemTemplate>
					<EditItemTemplate><asp:Label Text='<%#Eval("StateFrom") %>' runat="server" /></EditItemTemplate>
					<FooterTemplate>
						<UI:DropDownListEx ID="StateFromID" DataSourceID="dsStates" DataTextField="NameLong" DataValueField="ID" runat="server" AppendDataBoundItems="true">
							<asp:ListItem Selected="True" Text="Any" Value=""></asp:ListItem>
						</UI:DropDownListEx>
					</FooterTemplate>
				</asp:TemplateField>

				<asp:TemplateField HeaderText="To" SortExpression="StateTo">
					<ItemTemplate><asp:Label Text='<%#Eval("StateTo") %>' runat="server" /></ItemTemplate>
					<EditItemTemplate><asp:Label Text='<%#Eval("StateTo") %>' runat="server" /></EditItemTemplate>
					<FooterTemplate>
						<UI:DropDownListEx ID="StateToID" DataSourceID="dsStates" DataTextField="NameLong" DataValueField="ID" AppendDataBoundItems="true" runat="server">
							<asp:ListItem Selected="True" Text="Any" Value=""></asp:ListItem>
						</UI:DropDownListEx>
					</FooterTemplate>
				</asp:TemplateField>

				<asp:TemplateField HeaderText="Action Name" SortExpression="StateFlowActionName">
					<ItemStyle HorizontalAlign="Left" />
					<ItemTemplate><asp:Label Text='<%#Eval("StateFlowActionName") %>' Title='<%#Eval("StateFlowActionTextFull") %>' runat="server" /></ItemTemplate>
					<EditItemTemplate>
						<asp:HiddenField ID="hdnStateFromID" Value='<%# Bind("StateFromID") %>' runat="server" />
						<asp:HiddenField ID="hdnStateToID" Value='<%# Bind("StateToID") %>' runat="server" />
						<asp:DropDownList ID="selStateFlowActionID" DataSourceID="dsStateFlowActions" DataTextField="Name" DataValueField="ID" runat="server"
								 SelectedValue='<%# Bind("StateFlowActionID") %>'></asp:DropDownList>
					</EditItemTemplate>
					<FooterTemplate>
						<asp:DropDownList ID="StateFlowActionID" DataSourceID="dsStateFlowActions" DataTextField="Name" DataValueField="ID" runat="server"></asp:DropDownList>
					</FooterTemplate>
				</asp:TemplateField>

				<asp:TemplateField HeaderText="Priority" SortExpression="Priority">
					<ItemTemplate><asp:Label Text='<%#Eval("Priority") %>' runat="server" /></ItemTemplate>
					<EditItemTemplate><asp:TextBox ID="txtPriority" Text='<%#Bind("Priority") %>' runat="server" /></EditItemTemplate>
					<FooterTemplate><asp:TextBox ID="Priority" runat="server" /></FooterTemplate>
				</asp:TemplateField>

			</Columns>
		</OR:GridViewEx>
	</ContentTemplate>
</asp:UpdatePanel>

<DS:StateFlow_ActionsDataSource ID="ds" runat="server" />
<DS:StatesDataSource ID="dsStates" runat="server"  />
<DS:StateFlowActionsDataSource ID="dsStateFlowActions" runat="server" />
